{{extends file='admin/base.tpl'}}

{{block name='title'}}管理{{/block}}

{{block name='content'}}
<div class="container-fluid">
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">列表</h6>
        </div>
        <div class="card-body">
            <div class="mb-4">
                <a href="/admin//add" class="btn btn-primary">
                    <i class="fas fa-plus"></i> 添加
                </a>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>Id</th>
                <th>Title</th>
                <th>Content</th>
                <th>Author</th>
                <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {{foreach $data as $item}}
                        <tr>
                            <td>{{{$item.id}}}</td>
                    <td>{{{$item.title}}}</td>
                    <td>{{{$item.content}}}</td>
                    <td>{{{$item.author}}}</td>
                            <td>
                                <a href="/admin//edit?id={{{$item.id}}}" class="btn btn-warning btn-sm">编辑</a>
                                <a href="/admin//delete?id={{{$item.id}}}" class="btn btn-danger btn-sm delete-btn">删除</a>
                            </td>
                        </tr>
                        {{/foreach}}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<script>
// 删除确认
$(document).on('click', '.delete-btn', function(e) {
    e.preventDefault();
    if (confirm('确定要删除这条记录吗？')) {
        window.location.href = $(this).attr('href');
    }
});
</script>
{{/block}}